﻿package we3d.renderer.realistic 
{
	import we3d.View3d;
	import we3d.renderer.IRenderer
	import we3d.core.Camera3d;
	import we3d.scene.SceneObject;
	import we3d.math.Matrix3d;
	import we3d.mesh.Face;
	
	/**
	* Object Culling
	*/
	public class None implements IRenderer 
	{
		public function None () {}
		
		public function draw (view:View3d) :void 
		{
			var f:Number = view.scene.currentFrame;
			var objectList:Array = view.scene.objectList;
			var objs:int = objectList.length;
			var v:Camera3d = view.scene.cam;
			var cgv:Matrix3d = new Matrix3d();
			
			view.initFrame(f);
			
			var i:int;
			var L:int;
			var o:SceneObject;
			var j:int;
			var r:Array;
			var p:Face;
			
			for(i=0; i<objs; i++) 
			{
				o = objectList[i];
				
				// init transform and return culled
				if(o.initFrame(f, v, cgv)) continue;
				
				// init mesh and layer data 
				if(o.initMesh(view, cgv)) continue;
				
				// project points to 2d
				o.projectPoints(v, cgv);
				
				r = o.polygons;
				L = r.length;
				
				// render all polys
				for(j=0; j<L; j++) 
				{
					p = r[j];
					if(p.vLen < 2) continue;
					
					o.polyRenderer.drawPoly(view, p);
				}
			}
			
			view.endFrame(f);
		}
	}
}